package com.ymttest.database.sqlwapper.orderrisk;

import com.ymt.core.tool.FormatUtil;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.*;
import com.ymttest.database.model.godmch.chargeconfig;
import com.ymttest.database.model.godmch.chargeconfigExample;
import com.ymttest.database.model.godmch.subscriptioncharge;
import com.ymttest.database.model.godmch.subscriptionchargeExample;
import com.ymttest.database.model.godmch.subscriptionfunc;
import com.ymttest.database.model.godmch.subscriptionfuncExample;
import com.ymttest.database.model.godmch.subscriptionfuncExample.Criteria;
import com.ymttest.database.model.godmember.*;
import com.ymttest.database.model.orderrisk.HighRiskProduct;
import com.ymttest.database.model.orderrisk.HighRiskProductExample;
import com.ymttest.database.model.orderrisk.HighRiskSeller;
import com.ymttest.database.model.orderrisk.HighRiskSellerExample;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.YMTDateUtil;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class OrderRiskWapper {
	SqlManager manage;

	public OrderRiskWapper() {
		manage = new SqlManager("orderrisk");

	}
	
	/**
	 * 插入一条高风险商品
	 * @param ShopId
	 * @param NeedInvitationCode
	 * @return
	 * @throws InterruptedException
	 */
	public int insertHighRiskProduct(String pid) throws InterruptedException {
		if(pid==null) {
			return 0;
		}
		HighRiskProduct HighRiskProduct=new HighRiskProduct();
		HighRiskProduct.setProduct_id(pid);
		HighRiskProduct.setBad_comment_rate(new BigDecimal(0.1));
		HighRiskProduct.setRefund_rate(new BigDecimal(0.1));
		HighRiskProduct.setData_effective_date(YMTDateUtil.getSysTime("yyyyMMddHH"));
		HighRiskProduct.setAdd_time(YMTDateUtil.getDate());
		int i = manage.insert("com.ymttest.database.mapping.orderrisk.HighRiskMapper.insertHighRiskProduct", HighRiskProduct);
		manage.commit();
		return i;
	}
	/**
	 * 删除一条高风险商品
	 * @param ShopId
	 * @param NeedInvitationCode
	 * @return
	 * @throws InterruptedException
	 */
	public int deleteHighRiskProduct(String pid) throws InterruptedException {
		if(pid==null) {
			return 0;
		}
		HighRiskProductExample HighRiskProduct=new HighRiskProductExample();
		com.ymttest.database.model.orderrisk.HighRiskProductExample.Criteria c = HighRiskProduct.createCriteria();
		c.andProduct_idEqualTo(pid);
		int i = manage.delete("com.ymttest.database.mapping.orderrisk.HighRiskMapper.deleteHighRiskProduct", HighRiskProduct);
		manage.commit();
		return i;
	}
	
	/**
	 * 插入一条高风险商家
	 * @param ShopId
	 * @param NeedInvitationCode
	 * @return
	 * @throws InterruptedException
	 */
	public int insertHighRiskSeller(Integer sellerId) throws InterruptedException {
		if(sellerId==null) {
			return 0;
		}
		HighRiskSeller HighRiskSeller=new HighRiskSeller();
		HighRiskSeller.setSellerId(sellerId.longValue());
		HighRiskSeller.setBad_comment_rate(new BigDecimal(0.1));
		HighRiskSeller.setData_effective_date(YMTDateUtil.getSysTime("yyyyMMddHH"));
		HighRiskSeller.setAdd_time(YMTDateUtil.getDate());
		HighRiskSeller.setSuspected_sale((byte) 0);
		HighRiskSeller.setAbuse_user((byte) 0);
		HighRiskSeller.setPoor_deposit((byte) 0);
		HighRiskSeller.setPoor_service((byte) 0);
		HighRiskSeller.setDeposit("0.1");
		HighRiskSeller.setComplaint_rate(new BigDecimal(0.1));
		HighRiskSeller.setBad_comment_rate(new BigDecimal(0.1));
		HighRiskSeller.setBad_transaction_rate(new BigDecimal(0.1));
		int i = manage.insert("com.ymttest.database.mapping.orderrisk.HighRiskMapper.insertHighRiskSeller", HighRiskSeller);
		manage.commit();
		return i;
	}
	/**
	 * 删除一条高风险商家
	 * @param ShopId
	 * @param NeedInvitationCode
	 * @return
	 * @throws InterruptedException
	 */
	public int deleteHighRiskSeller(Integer sellerid) throws InterruptedException {
		if(sellerid==null) {
			return 0;
		}
		HighRiskSellerExample HighRisk=new HighRiskSellerExample();
		com.ymttest.database.model.orderrisk.HighRiskSellerExample.Criteria c = HighRisk.createCriteria();
		c.andSellerIdEqualTo(sellerid.longValue());
		int i = manage.delete("com.ymttest.database.mapping.orderrisk.HighRiskMapper.deleteHighRiskSeller", HighRisk);
		manage.commit();
		return i;
	}
	//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	
	public static void main(String args[]) throws InterruptedException {
		OrderRiskWapper DefWapper=new OrderRiskWapper();
		System.out.println(DefWapper.insertHighRiskProduct("pid1"));
		System.out.println(DefWapper.deleteHighRiskProduct("pid1"));
		
		System.out.println(DefWapper.insertHighRiskSeller(1));
		System.out.println(DefWapper.deleteHighRiskSeller(1));
	}
}
